<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>新增页面</title>
  <link rel="stylesheet" href="../../../component/pear/css/pear.css"/>
</head>
<body>
<form class="layui-form" action="">
  <div class="mainBox">
    <div class="main-container">
      <div class="layui-form-item">
        <label class="layui-form-label">产品绑定测评Id</label>
        <div class="layui-input-block">
          <input type="text" name="evaId" th:value="${product.evaId}" lay-verify="title" autocomplete="off"
                 placeholder="请输入标题"
                 class="layui-input">
        </div>
      </div>
<!--      <div class="layui-form-item">-->
<!--        <label class="layui-form-label">产品名称</label>-->
<!--        <div class="layui-input-block">-->
<!--          <input type="text" name="name" th:value="${product.title}" lay-verify="title" autocomplete="off"-->
<!--                 placeholder="请输入标题"-->
<!--                 class="layui-input">-->
<!--        </div>-->
<!--      </div>-->
      <div class="layui-form-item">
        <label class="layui-form-label">价格</label>
        <div class="layui-input-block">
          <!--/*@thymesVar id="price" type="tech.maiquer.metrichall.wxpay.entity.Product"*/-->
          <input type="text" name="price" th:value="${product.price}" lay-verify="title" autocomplete="off" placeholder="请输入标题"
                 class="layui-input">
        </div>
      </div>
    </div>
  </div>
  <div class="bottom">
    <div class="button-container">
      <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
              lay-filter="product-save">
        <i class="layui-icon layui-icon-ok"></i>
        提交
      </button>
      <button type="reset" class="pear-btn pear-btn-sm">
        <i class="layui-icon layui-icon-refresh"></i>
        重置
      </button>
    </div>
  </div>
</form>
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
  layui.use(['form', 'jquery'], function () {
    let form = layui.form;
    let $ = layui.jquery;

    form.on('submit(product-save)', function (data) {
      console.log(data)
      $.ajax({
        url: '/api/product/addProduct',
        data: JSON.stringify(data.field),
        dataType: 'json',
        contentType: 'application/json',
        type: 'post',
        success: function (result) {
          if (result.code === 0) {
            layer.msg(result.message, {
              icon: 1,
              time: 1000
            }, function () {
              parent.layer.close(parent.layer.getFrameIndex(window
                      .name)); //关闭当前页
              parent.layui.table.reload("product-table");
            });
          } else {
            layer.msg(result.message, {
              icon: 2,
              time: 1000
            });
          }
        }
      })
      return false;
    });
  })
</script>
<script>
</script>
</body>
</html>
